package chapter11

import org.apache.spark.sql.SparkSession

/**
 * author: yuhui
 * descriptions:
 * date: 2024 - 09 - 02 4:00 下午
 */
object UDF01 {

  def main(args: Array[String]): Unit = {

    val spark: SparkSession = SparkSession
      .builder()
      .appName("")
      .master("local[*]")
      .getOrCreate()

    val df = spark.read.json("doc/input/09student.json")

    df.show()

    spark.udf.register("addName", (x: String) => "Name:" + x)

    df.createOrReplaceTempView("people")

    spark.sql("Select addName(name), score from people").show()

  }

}